var uname = new String("zhangsan")
uname = "lisi"

// 属性
console.log(uname.constructor)
console.log(uname.length)

// 方法
console.log(uname.charAt(1));
console.log(uname.charCodeAt(1))
console.log(uname.concat(" good"))
console.log(uname.indexOf("s"))
console.log(uname.lastIndexOf("s"))
// 比较字符串，返回数字，相同为0
var index = "zhangsan".localeCompare("zhangsan ")
console.log("index:"+index)

var str3 = "again ain gain";
var n = str3.match("/ain/g")
console.log("正则匹配:"+n)

var reg = /(\w+)\s(w+)/;
var str4 = "ali sara";
// 注意这里是 “$2 $1” 交换
var newStr = str4.replace(reg, "$2 $1")
console.log(newStr)

// 按正则搜索是否包含 ali，不包含返回 -1
console.log("是否包含ali:"+ str4.search(/ali/))
// 切片
console.log(str4.slice(0, 2))
// 可以指定分割的数量，比如1
console.log(str4.split(" ", 1))

console.log(str4.substring(0, 1))
console.log(str4.toLocaleLowerCase())
console.log(str4.toLocaleUpperCase())
console.log(str4.toLowerCase())
console.log(str4.toUpperCase())
console.log(str4.toString())
console.log(str4.valueOf())
console.log(typeof str4.valueOf())





